//
//  SoundMgr.m
//  Ropewalker
//
//  Created by huang kun on 7/3/10.
//  Copyright 2010 UESTC. All rights reserved.
//

#import "SoundMgr.h"
#import "SimpleAudioEngine.h"
#import "CarDemoAppDelegate.h"

@implementation SoundMgr


+ (void) playSound:(SoundType)type {
	switch (type) {
		case ksoundPlane:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_plane.wav"];
			break;
		case ksoundBird:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_bird.wav"];
			break;
		case ksoundWind:
		{
			[self stopBackgroundMusic];
			[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"sound_wind.wav"];
		}
			break;
		case ksoundButton:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_button.mp3"];
			break;
		case ksoundNewspaper:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_newspaper.mp3"];
			break;
		case ksoundStart:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_start.wav"];
			break;
		case ksoundDanger:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_danger.wav"];
			break;
		case ksoundFail1:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_failed_1.wav"];
			break;
		case ksoundFail2:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_failed_2.mp3"];
			break;
		case ksoundSuccess1:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_success_1.wav"];
			break;
		case ksoundSuccess2:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_success_2.mp3"];
			break;
		case ksoundCloud:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_cloud.mp3"];
			break;
		case ksoundCloud2:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_cloud_2.mp3"];
			break;
		case ksoundCans:
			[[SimpleAudioEngine sharedEngine] playEffect:@"sound_cans.mp3"];
			break;
		case kloopSoundDay:
		{
			[self stopBackgroundMusic];
			[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"sound_bg_day.mp3"];
		}
			break;
		case kloopSoundNight:
		{
			[self stopBackgroundMusic];
			[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"sound_bg_night.mp3"];
		}
			break;
		case kloopSoundStart:
		{
			[self stopBackgroundMusic];
			[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"sound_bg_start.mp3"];
		}
			break;
		default:
			break;
	}
}

+ (void) stopBackgroundMusic {
	[[SimpleAudioEngine sharedEngine] stopBackgroundMusic];
}

+ (void) playVibrate {
	CarDemoAppDelegate *delegate = (CarDemoAppDelegate *)[[UIApplication sharedApplication] delegate];
	if( delegate.isVibrateOn )
		AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}

@end
